package com.webapp.manager.impl;

import java.util.List;

import com.webapp.basedata.User;
import com.webapp.dao.impl.UserDaoImpl;
import com.webapp.manager.UserManager;

public class UserManagerImpl implements UserManager {

	@Override
	public void addUser(String account, String password, String name) {
		UserDaoImpl daoImpl = new UserDaoImpl();
		User user = new User();
		user.setAccount(account);
		user.setPassword(password);
		user.setName(name);
		daoImpl.addUser(user);
	}

	@Override
	public User findUserById(int id) {
		UserDaoImpl daoImpl = new UserDaoImpl();
		return daoImpl.findUserById(id);
	}

	@Override
	public User findUserByAccount(String account) {
		UserDaoImpl daoImpl = new UserDaoImpl();
		User user = daoImpl.findUserByAccount(account);
		return user;
	}

	@Override
	public void modifyUser(int id, String account, String name) {
		UserDaoImpl daoImpl = new UserDaoImpl();
		User user = daoImpl.findUserById(id);
		user.setAccount(account);
		user.setName(name);
		daoImpl.modifyUser(user);
	}

	@Override
	public void deleteUserById(int id) {
		UserDaoImpl daoImpl = new UserDaoImpl();
		daoImpl.deleteUser(id);
	}

	@Override
	public boolean login(String account, String password) {
		UserDaoImpl daoImpl = new UserDaoImpl();
		return daoImpl.login(account, password);
	}

	@Override
	public List<User> seachUsers() {
		UserDaoImpl daoImpl = new UserDaoImpl();
		return daoImpl.seachUsers();
	}

}
